home *** CD-ROM | disk | FTP | other *** search
/ Network PC / Network PC.iso / amiga utilities / communication / bbs / hydrabbsa8 / source / src.lha / utils / userviewer / UserViewer.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-09-08  |  5.4 KB  |  201 lines

  1.  
  2.  
  3. /*********************************************/
  4. /*                                           */
  5. /*       Designer (C) Ian OConnor 1994       */
  6. /*                                           */
  7. /*      Designer Produced C include file     */
  8. /*                                           */
  9. /*********************************************/
  10.  
  11. #include <exec/types.h>
  12. #include <exec/memory.h>
  13. #include <dos/dosextens.h>
  14. #include <intuition/screens.h>
  15. #include <intuition/intuition.h>
  16. #include <intuition/gadgetclass.h>
  17. #include <libraries/gadtools.h>
  18. #include <diskfont/diskfont.h>
  19. #include <utility/utility.h>
  20. #include <graphics/gfxbase.h>
  21. #include <workbench/workbench.h>
  22. #include <graphics/scale.h>
  23. #include <clib/exec_protos.h>
  24. #include <clib/wb_protos.h>
  25. #include <clib/intuition_protos.h>
  26. #include <clib/gadtools_protos.h>
  27. #include <clib/graphics_protos.h>
  28. #include <clib/utility_protos.h>
  29. #include <string.h>
  30. #include <clib/diskfont_protos.h>
  31.  
  32. #include "UserViewer.h"
  33.  
  34.  
  35. ULONG BevelTags[] =
  36.   {
  37.   (GTBB_Recessed), TRUE,
  38.   (GT_VisualInfo), 0,
  39.   (TAG_DONE)
  40.   };
  41.  
  42. struct IntuiText UVTexts[] =
  43.   {
  44.   2, 3, JAM1, 164, 74, &topa81281, (UBYTE *)"User Viewer (C) 1995 D.Clifton - Deluxe Software Ltd.", NULL
  45.   };
  46.  
  47. struct Window *UV = NULL;
  48. APTR UVVisualInfo;
  49. APTR UVDrawInfo;
  50. struct Gadget *UVGList;
  51. struct Gadget *UVGadgets[3];
  52. UBYTE UVFirstRun = 0;
  53.  
  54. ULONG UVGadgetTags[] =
  55.   {
  56.   (GTLV_ShowSelected), 0,
  57.   (GTLV_Selected), 0,
  58.   (TAG_END),
  59.   };
  60.  
  61. UWORD UVGadgetTypes[] =
  62.   {
  63.   LISTVIEW_KIND,
  64.   BUTTON_KIND,
  65.   BUTTON_KIND,
  66.   };
  67.  
  68. struct NewGadget UVNewGadgets[] =
  69.   {
  70.   1, 1, 590, 68, NULL, &topaz800, LV1, 1, NULL,  (APTR)&UVGadgetTags[0],
  71.   1, 70, 78, 16, (UBYTE *)"About", &topaz800, UV_ABOUT, 16, NULL,  NULL,
  72.   79, 70, 78, 16, (UBYTE *)"Update", &topaz800, UV_UPDATE, 16, NULL,  NULL,
  73.   };
  74. UWORD UVZoomInfo[4] = { 0, 0, 200, 11 };
  75.  
  76. struct TextAttr topa81281 = { (STRPTR)"topaz", 8, 128, 1 };
  77. struct TextAttr topaz800 = { (STRPTR)"topaz.font", 8, 0, 0 };
  78.  
  79. void RendWindowUV( struct Window *Win, void *vi )
  80. {
  81. int loop;
  82. UWORD offx = Win->BorderLeft;
  83. UWORD offy = Win->BorderTop;
  84. if (Win != NULL)
  85.   {
  86.   BevelTags[3] = (ULONG)vi;
  87.   DrawBevelBoxA( Win->RPort, 158+offx,70+offy,433,16, (struct TagItem *)(&BevelTags[2]));
  88.   for( loop=0; loop<1; loop++)
  89.     if (UVTexts[loop].ITextFont==NULL)
  90.       UVTexts[loop].ITextFont=Win->WScreen->Font;
  91.   PrintIText( Win->RPort, UVTexts, offx, offy);
  92.   }
  93. }
  94.  
  95. int OpenWindowUV( void )
  96. {
  97. struct Screen *Scr;
  98. UWORD offx, offy;
  99. UWORD loop;
  100. struct NewGadget newgad;
  101. struct Gadget *Gad;
  102. struct Gadget *Gad2;
  103. APTR Cla;
  104. if (UVFirstRun == 0)
  105.   {
  106.   UVFirstRun = 1;
  107.   }
  108. if (UV == NULL)
  109.   {
  110.   Scr = LockPubScreen((UBYTE *)"CtrlScrn");
  111.   if (NULL != Scr)
  112.     {
  113.     offx = Scr->WBorLeft;
  114.     offy = Scr->WBorTop + Scr->Font->ta_YSize+1;
  115.     if (NULL != ( UVVisualInfo = GetVisualInfoA( Scr, NULL)))
  116.       {
  117.       if (NULL != ( UVDrawInfo = GetScreenDrawInfo( Scr)))
  118.         {
  119.         UVGList = NULL;
  120.         Gad = CreateContext( &UVGList);
  121.         for ( loop=0 ; loop<3 ; loop++ )
  122.           if (UVGadgetTypes[loop] != 198)
  123.             {
  124.             CopyMem((char * )&UVNewGadgets[loop], ( char * )&newgad, (long)sizeof( struct NewGadget ));
  125.             newgad.ng_VisualInfo = UVVisualInfo;
  126.             newgad.ng_LeftEdge += offx;
  127.             newgad.ng_TopEdge += offy;
  128.             UVGadgets[ loop ] = NULL;
  129.             UVGadgets[ newgad.ng_GadgetID - UVFirstID ] = Gad = CreateGadgetA( UVGadgetTypes[loop], Gad, &newgad, newgad.ng_UserData );
  130.             }
  131.         for ( loop=0 ; loop<3 ; loop++ )
  132.           if (UVGadgetTypes[loop] == 198)
  133.             {
  134.             UVGadgets[ loop ] = NULL;
  135.             Cla = NULL;
  136.             if (Gad)
  137.               UVGadgets[ loop ] = Gad2 = (struct Gadget *) NewObjectA( (struct IClass *)Cla, UVNewGadgets[ loop ].ng_GadgetText, UVNewGadgets[ loop ].ng_UserData );
  138.             }
  139.         if (Gad != NULL)
  140.           {
  141.           if (NULL != (UV = OpenWindowTags( NULL, (WA_Left), 15,
  142.                   (WA_Top), 119,
  143.                   (WA_Width), 596+offx,
  144.                   (WA_Height), 89+offy,
  145.                   (WA_Title), "User Viewer",
  146.                   (WA_ScreenTitle), "User Viewer (C) 1995 Dominic Clifton - Deluxe Software Ltd.",
  147.                   (WA_MinWidth), 200,
  148.                   (WA_MinHeight), 11,
  149.                   (WA_MaxWidth), 1200,
  150.                   (WA_MaxHeight), 1200,
  151.                   (WA_DragBar), TRUE,
  152.                   (WA_DepthGadget), TRUE,
  153.                   (WA_CloseGadget), TRUE,
  154.                   (WA_Activate), TRUE,
  155.                   (WA_Dummy+0x30), TRUE,
  156.                   (WA_SmartRefresh), TRUE,
  157.                   (WA_AutoAdjust), TRUE,
  158.                   (WA_Gadgets), UVGList,
  159.                   (WA_Zoom), UVZoomInfo,
  160.                   (WA_PubScreen) , (LONG)Scr,
  161.                   (WA_IDCMP),4194940,
  162.                   (TAG_END))))
  163.             {
  164.             RendWindowUV(UV, UVVisualInfo );
  165.             GT_RefreshWindow( UV, NULL);
  166.             RefreshGList( UVGList, UV, NULL, ~0);
  167.             UnlockPubScreen( NULL, Scr);
  168.             return( 0L );
  169.             }
  170.           }
  171.         FreeGadgets( UVGList);
  172.         FreeScreenDrawInfo( Scr, UVDrawInfo );
  173.         }
  174.       FreeVisualInfo( UVVisualInfo );
  175.       }
  176.     UnlockPubScreen( NULL, Scr);
  177.     }
  178.   }
  179. else
  180.   {
  181.   WindowToFront(UV);
  182.   ActivateWindow(UV);
  183.   return( 0L );
  184.   }
  185. return( 1L );
  186. }
  187.  
  188. void CloseWindowUV( void )
  189. {
  190. if (UV != NULL)
  191.   {
  192.   FreeScreenDrawInfo( UV->WScreen, UVDrawInfo );
  193.   UVDrawInfo = NULL;
  194.   CloseWindow( UV);
  195.   UV = NULL;
  196.   FreeVisualInfo( UVVisualInfo);
  197.   FreeGadgets( UVGList);
  198.   }
  199. }
  200.  
  201.